package cn.legend.travel.admin.authorize.controller;

import cn.legend.travel.admin.authorize.service.IFrontendMenuService;
import cn.legend.travel.common.pojo.authentication.CurrentPrincipal;
import cn.legend.travel.common.web.JsonResult;
import com.baomidou.mybatisplus.extension.api.ApiController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

@Api(tags = "前端菜单管理模块")
@RestController
@Validated
@RequestMapping("menus")
@RequiredArgsConstructor
public class FrontendMenuController extends ApiController {
    private final IFrontendMenuService service;

    @GetMapping("list")
    @ApiOperation("根据角色id获取菜单列表")
    public JsonResult getMenuByRoleId(@ApiIgnore @AuthenticationPrincipal CurrentPrincipal principal) {
        return JsonResult.ok(service.getMenuByRoleId(principal.getId()));
    }
}
